//
//  NYMyExamineDetailView.m
//  
//
//  Created by MinLison on 2018/1/8.
//

#import "NYMyExamineDetailView.h"
#import "AAChartView.h"
@interface NYMyExamineDetailView ()
//@property(nonatomic, strong) TTTAttributedLabel *titleLabel;
//@property(nonatomic, strong) TTTAttributedLabel *desLabel;
//@property(nonatomic, strong) TTTAttributedLabel *subTitleLabel;
//@property(nonatomic, strong) TTTAttributedLabel *subDesLabel;
//@property(nonatomic, strong) UIView *pieChartContentView;
//@property (nonatomic, strong) AAChartView *pieChart;
//@property(nonatomic, strong) AAChartModel *aaChartModel;
@end
@implementation NYMyExamineDetailView
//- (void)setDetailModel:(NYMyExamineDetailModel *)detailModel
//{
//        _detailModel = detailModel;
//        [self updateContent];
//}
//- (void)updateContent
//{
//        if (!self.detailModel)
//        {
//                return;
//        }
//        self.titleLabel.text = self.detailModel.page_info.examine_title;
//
//        NSString *desString = [NSString stringWithFormat:@"本试卷总%d题，共计100分,第一次得分为%d分，本次得分%d分",self.detailModel.page_info.num.intValue,self.detailModel.page_info.achievement.intValue,self.detailModel.page_info.examine_score.intValue];
//        [self.desLabel setText:desString afterInheritingLabelAttributesAndConfiguringWithBlock:^NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {
//                NSRegularExpression *regular = [NSRegularExpression regularExpressionWithPattern:@"\\d+" options:(0) error:nil];
//                [[regular matchesInString:mutableAttributedString.string options:(0) range:NSMakeRange(0, mutableAttributedString.string.length)] enumerateObjectsUsingBlock:^(NSTextCheckingResult * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
//                        if (idx > 1) {
//                                [mutableAttributedString addAttribute:(NSString *)kCTForegroundColorAttributeName value:(id)(UIColorHex(0xFF6F40).CGColor) range:obj.range];
//                        }
//                }];
//                return mutableAttributedString;
//        }];
//        self.subTitleLabel.text = @"所有同学答题情况";
//        NSString *subDesString = [NSString stringWithFormat:@"总答题人数%d人,回答情况如下：",self.detailModel.page_info.answer_num.intValue];
//
//        [self.subDesLabel setText:subDesString afterInheritingLabelAttributesAndConfiguringWithBlock:^NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {
//                NSRegularExpression *regular = [NSRegularExpression regularExpressionWithPattern:@"\\d+" options:(0) error:nil];
//                [[regular matchesInString:mutableAttributedString.string options:(0) range:NSMakeRange(0, mutableAttributedString.string.length)] enumerateObjectsUsingBlock:^(NSTextCheckingResult * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
//                        [mutableAttributedString addAttribute:(NSString *)kCTForegroundColorAttributeName value:(id)(UIColorHex(0xFF6F40).CGColor) range:obj.range];
//                }];
//                return mutableAttributedString;
//        }];
//        [self createPieChartView];
//}
//- (void)createPieChartView
//{
////        [self.pieChartContentView removeAllSubviews];
//        NSMutableArray *items = [NSMutableArray arrayWithCapacity:self.detailModel.score_statistics.count];
//        NSMutableArray *colors = [NSMutableArray arrayWithCapacity:self.detailModel.score_statistics.count];
//        [self.detailModel.score_statistics enumerateObjectsUsingBlock:^(NYMyExamineScoreModel * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
//                [items addObject:@[[NSString stringWithFormat:@"%@  %.2f%%",obj.group_name,obj.score.floatValue],obj.score.numberValue]];
//                [colors addObject:obj.color];
//        }];
//        AAChartModel *aaChartModel= AAObject(AAChartModel)
//        .chartTypeSet(AAChartTypePie)
//        .colorsThemeSet(colors)
//        .titleSet(@"")
//        .subtitleSet(@"")
//        .dataLabelEnabledSet(true)//是否直接显示扇形图数据
//        .yAxisTitleSet(@"总百分比")
//        .seriesSet(@[AAObject(AASeriesElement)
//                     .nameSet(@"总百分比")
//                     .innerSizeSet(@"30%")
//                     .dataSet(items)]);
//        self.aaChartModel = aaChartModel;
//        [self.pieChart aa_drawChartWithChartModel:aaChartModel];
//}
//
//- (void)setupView
//{
//        [super setupView];
//        [self addSubview:self.titleLabel];
//        [self addSubview:self.desLabel];
//        [self addSubview:self.subTitleLabel];
//        [self addSubview:self.subDesLabel];
//        self.pieChartContentView = [[UIView alloc] init];
//        self.pieChartContentView.backgroundColor = [UIColor clearColor];
//        [self addSubview:self.pieChartContentView];
//
//        [self.titleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
//
//                if (@available(iOS 11.0,*))
//                {
//                        make.top.equalTo(self.mas_safeAreaLayoutGuideTop).offset(__WGHeight(24));
//                        make.left.equalTo(self.mas_safeAreaLayoutGuideLeft).offset(__WGWidth(22));
//                        make.right.equalTo(self.mas_safeAreaLayoutGuideRight).offset(-__WGWidth(22));
//                }
//                else
//                {
//                        make.top.equalTo(self.controller.mas_topLayoutGuideBottom).offset(__WGHeight(24));
//                        make.left.equalTo(self).offset(__WGWidth(22));
//                        make.right.equalTo(self).offset(-__WGWidth(22));
//                }
//                make.centerX.equalTo(self.mas_centerX);
//        }];
//
//        [self.desLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
//                make.top.equalTo(self.titleLabel.mas_bottom).offset(__WGHeight(18));
//                make.left.right.equalTo(self.titleLabel);
//                make.height.mas_equalTo(__WGHeight(30));
//        }];
//
//        [self.subTitleLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
//                make.top.equalTo(self.desLabel.mas_bottom).offset(__WGHeight(25));
//                make.left.right.equalTo(self.titleLabel);
//        }];
//
//        [self.subDesLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
//                make.top.equalTo(self.subTitleLabel.mas_bottom).offset(__WGHeight(38));
//                if (@available(iOS 11.0,*))
//                {
//                        make.left.equalTo(self.mas_safeAreaLayoutGuideLeft).offset(__WGWidth(15));
//                        make.right.equalTo(self.mas_safeAreaLayoutGuideRight).offset(-__WGWidth(15));
//                }
//                else
//                {
//                        make.left.equalTo(self).offset(__WGWidth(15));
//                        make.right.equalTo(self).offset(-__WGWidth(15));
//                }
//        }];
//
//        [self.pieChartContentView mas_remakeConstraints:^(MASConstraintMaker *make) {
//                make.top.equalTo(self.subDesLabel.mas_bottom).offset(__WGHeight(23));
//                if (@available(iOS 11.0,*))
//                {
//                        make.left.equalTo(self.mas_safeAreaLayoutGuideLeft).offset(__WGWidth(0));
//                        make.right.equalTo(self.mas_safeAreaLayoutGuideRight).offset(-__WGWidth(0));
//                        make.bottom.equalTo(self.mas_safeAreaLayoutGuideBottom);
//                }
//                else
//                {
//                        make.left.equalTo(self).offset(__WGWidth(0));
//                        make.right.equalTo(self).offset(-__WGWidth(0));
//                        make.bottom.equalTo(self.controller.mas_bottomLayoutGuideTop);
//                }
//        }];
//
//        self.pieChart = [[AAChartView alloc] init];
//        self.pieChart.isClearBackgroundColor = YES;
//        [self.pieChartContentView addSubview:self.pieChart];
//
//        [self.pieChart mas_remakeConstraints:^(MASConstraintMaker *make) {
//                make.top.equalTo(self.pieChartContentView.mas_top);
//                make.height.mas_equalTo(__WGHeight(250));
//                make.left.right.equalTo(self.pieChartContentView);
//        }];
//}
//
///// MARK: - Lazy
//- (TTTAttributedLabel *)titleLabel
//{
//        if (_titleLabel == nil) {
//                _titleLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectZero];
//                _titleLabel.font = WGSystem18Font;
//                _titleLabel.textColor = UIColorHex(0x333333);
//                _titleLabel.textAlignment = NSTextAlignmentCenter;
//                [_titleLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultLow) forAxis:(UILayoutConstraintAxisHorizontal)];
//        }
//        return _titleLabel;
//}
//- (TTTAttributedLabel *)desLabel
//{
//        if (_desLabel == nil) {
//                _desLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectZero];
//                _desLabel.font = WGSystem11Font;
//                _desLabel.textColor = UIColorHex(0x999999);
//                _desLabel.textAlignment = NSTextAlignmentCenter;
//                _desLabel.layer.cornerRadius = 15;
//                _desLabel.clipsToBounds = YES;
//                _desLabel.textInsets = UIEdgeInsetsMake(0, __WGWidth(8), 0, __WGWidth(8));
//                _desLabel.backgroundColor = UIColorForBackground;
//                [_desLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultLow) forAxis:(UILayoutConstraintAxisHorizontal)];
//        }
//        return _desLabel;
//}
//- (TTTAttributedLabel *)subTitleLabel
//{
//        if (_subTitleLabel == nil) {
//                _subTitleLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectZero];
//                _subTitleLabel.font = WGSystem14Font;
//                _subTitleLabel.textColor = UIColorHex(0x333333);
//                _subTitleLabel.textAlignment = NSTextAlignmentCenter;
//                [_subTitleLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultLow) forAxis:(UILayoutConstraintAxisHorizontal)];
//        }
//        return _subTitleLabel;
//}
//- (TTTAttributedLabel *)subDesLabel
//{
//        if (_subDesLabel == nil) {
//                _subDesLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectZero];
//                _subDesLabel.font = WGSystem13Font;
//                _subDesLabel.textColor = UIColorHex(0x333333);
//                [_subDesLabel setContentCompressionResistancePriority:(UILayoutPriorityDefaultLow) forAxis:(UILayoutConstraintAxisHorizontal)];
//        }
//        return _subDesLabel;
//}

@end
